﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Industry_Edit.aspx.cs" Inherits="TimKen.Web.Admin.Industry_Edit" %>

<%@ Register TagPrefix="FCKeditorV2" Namespace="FredCK.FCKeditorV2" Assembly="FredCK.FCKeditorV2" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentLinkAction" runat="server">
 
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentTitle" runat="server">
 应用行业维护
</asp:Content>


<asp:Content ID="Content3" ContentPlaceHolderID="ContentMain" runat="server">
<div style="display:none"><asp:Button ID="HideBtn" runat="server" Text="删除分类" onclick="HideBtn_Click" />
<asp:TextBox ID="HideTextBox" runat="server"></asp:TextBox></div>

   <script type="text/javascript">
     var treeview;
     function flyTreeView_onInitialized(treeviewObject) {
         treeview = treeviewObject;
 
     }
     function HandleContextMenuPopup(sender, node, event) {
         var nodeContextMenuID = node.getContextMenuID();
         if (node.getContextMenuID().length == 0) return;

         var expandEnabled = node.getChildNodes().length > 0 && !node.getExpanded();
         var collapseEnabled = node.getChildNodes().length > 0 && node.getExpanded();
         var isLeaf = (node.getChildNodes().length <= 0 ? true : false);
         var isroot = (node.getLevel() == 0 ? true : false);
         var contextMenu = CFlyContextMenu.getInstanceById("<%=ContextMenuFolder.ClientID%>");
         var items = contextMenu.getItems();
         for (var i = 0; i < items.length; i++) {
             switch (items[i].getCommandName()) {
                 case "Expand":
                     items[i].setDisabled(!expandEnabled);
                     break;
                 case "Collapse":
                     items[i].setDisabled(!collapseEnabled);
                     break;
                 case "DelChildItem":
                     items[i].setDisabled(isroot);
                     break;
                 case "ProductManage":
                     items[i].setDisabled(isroot || !isLeaf);
                     break;
             }
         }
     }

     function ExpandNode(item, argument) {
         var node = argument;
         node.expand();
     }
     function CollapseNode(item, argument) {
         var node = argument;
         node.collapse();
       }

       function ModifyNode(item, argument) {
         var node = argument;
         document.URL = "Industry_Add.aspx?IndustryID=" + node.getValue();
       }
       function AddChild(item, argument) {
         var node = argument;
         document.URL = "Industry_Add.aspx?ParentID=" + node.getValue();
       }

       function DeleteNode(item, argument) {
         var node = argument;
         if (confirm("你确定删除分类【" + node.getText() + "】吗？")) {

           document.getElementById('<%=this.HideTextBox.ClientID%>').value = node.getValue();
           document.getElementById('<%=this.HideBtn.ClientID%>').click();

         }
       }

       function ProductManage(item, argument) {
           var node = argument;
           document.URL = "Industry_Product.aspx?IndustryID=" + node.getValue();
       }
       
      </script>
    
    <NineRays:FlyTreeView ID="FlyTreeView1" runat="server" BackColor="White" ImageSet="MacOS"
                    BorderColor="Silver" BorderWidth="1px" Height="600px"    PostBackOnSelect="true"
        Width="100%" Padding="2px"    
                     SlideEffect="True"    ContextMenuID="ContextMenuFolder"    
        OnContextMenuJavascript="HandleContextMenuPopup"     OnInitializedJavascript="flyTreeView_onInitialized"
         >
                     <DefaultStyle Font-Names="Verdana" Font-Size="11px" ForeColor="Black" Padding="2px;4px;4px;2px"
                        RowHeight="18px" ImageUrl="$kde_folder" />
                    <SelectedStyle BackColor="68, 123, 205" BorderColor="150, 150, 150" BorderWidth="1px"
                        Padding="1px;3px;3px;1px" BorderStyle="Solid" ForeColor="White" />
                    <HoverStyle Font-Underline="True" />
                    <DataBindings>
                    <NineRays:FlyNodeBinding  TextField="NameCn"   ValueField="IndustryID"  />
                    </DataBindings>
                </NineRays:FlyTreeView>
                
      <NineRays:FlyContextMenu ID="ContextMenuFolder" runat="server">
                    <Items>
                        <NineRays:FlyMenuItem Text="展开" Javascript="ExpandNode(item, argument);" CommandName="Expand" />
                        <NineRays:FlyMenuItem Text="收缩" Javascript="CollapseNode(item, argument);"
                            CommandName="Collapse" />
                            
                            <NineRays:FlyMenuItem CommandName="ModifyItem" 
                            Javascript="ModifyNode(item, argument);" Text="修改" />
                             <NineRays:FlyMenuItem Text="删除" Javascript="DeleteNode(item, argument);"   CommandName="DelChildItem" />
                              <NineRays:FlyMenuItem CommandName="AddChild" 
                            Javascript="AddChild(item, argument);" Text="添加子行业" />
                              <NineRays:FlyMenuItem CommandName="ProductManage" 
                            Javascript="ProductManage(item, argument);" Text="维护产品" />
                    </Items>
                </NineRays:FlyContextMenu>
                
</asp:Content>

